<template>
	<view class="tabs">
		<view class="tabsLeft">
			<view v-for="(item,index) in tabsList" :key="index" :class="{tabs_active:index === tabsCurrent}" @click="changeTabs(index,item.id)">
				{{item.label}}
			</view>
		</view>
		<view class="tabsRight">
			<slot name="right"></slot>
		</view>
	</view>
</template>

<script setup>
	import {ref} from 'vue'
	const props = defineProps({
		tabsList:{
			type:Array,
			default:()=>[]
		},
	})
	const emit = defineEmits(["change"])
	const tabsCurrent = ref(0)
	const changeTabs = (index,id)=>{
		tabsCurrent.value = index
		emit("change",id)
	}
	defineExpose({
		changeTabs
	})
</script>

<style lang="less" scoped>
	.tabs{
		margin-top: 32rpx;
		display: flex;
		justify-content: space-between;
		.tabsLeft{
			display: flex;
			flex-grow: 1;
			view{
				margin-right: 20rpx;
				font-weight: 500;
				font-size: 28rpx;
				color: #767676;
				padding: 0 10rpx;
				&:last-child{
					margin-right: 0;
				}
				padding-bottom: 15rpx;
			}
		}
		.tabs_active{
			position: relative;
			color: #2778FF !important;
			font-size: 30rpx !important;
			font-weight: 550 !important;
			&::after{
				position: absolute;
				bottom: 0;
				left: 50%;
				transform: translateX(-50%);
				display: block;
				width: 56rpx;
				height: 6rpx;
				border-radius: 8rpx;
				background-color:#2778FF;
				content: "";
				
			}
		}
		.tabsRight{

		}
	}
</style>